home *** CD-ROM | disk | FTP | other *** search
/ Champak 128 / Vol 128 (Damaged).iso / games / rocketbi.swf / scripts / frame_2 / DoAction.as < prev   
Encoding:
Text File  |  2011-03-26  |  9.3 KB  |  389 lines

  1. function setscreen(sc)
  2. {
  3.    var _loc1_ = sc;
  4.    if(_loc1_ == "back")
  5.    {
  6.       loopb = true;
  7.       front[7]._visible = false;
  8.       while(loopb)
  9.       {
  10.          loopb = false;
  11.          screen = backscreen[screencounter];
  12.          screencounter--;
  13.          if(screencounter <= 1)
  14.          {
  15.             front[4].choice.gotoAndStop("new");
  16.          }
  17.          if(screen == "about" or screen == "help")
  18.          {
  19.             loopb = true;
  20.          }
  21.       }
  22.    }
  23.    else if(_loc1_ == "reset")
  24.    {
  25.       front[7]._visible = false;
  26.       screencounter = 0;
  27.       front[4].choice.gotoAndStop("new");
  28.    }
  29.    else
  30.    {
  31.       screencounter++;
  32.       backscreen[screencounter] = screen;
  33.       screen = _loc1_;
  34.    }
  35. }
  36. function useweapon(who)
  37. {
  38.    var _loc1_ = who;
  39.    if(weaponcounter[_loc1_] >= 1 and mode[_loc1_] == "ground")
  40.    {
  41.       weaponcounter[_loc1_]--;
  42.       if(weaponcounter[_loc1_] < 1)
  43.       {
  44.          weaponface.gotoAndStop(1);
  45.          weapon[_loc1_] = null;
  46.       }
  47.       tracklength++;
  48.       obstacles.attachMovie("obstacle",tracklength,tracklength);
  49.       obstacles[tracklength].kind = weapon[_loc1_];
  50.       if(_loc1_ == human)
  51.       {
  52.          obstacles[tracklength].human = true;
  53.       }
  54.       playsound("drop");
  55.       if(xvel[_loc1_] > 0)
  56.       {
  57.          margin = -50;
  58.       }
  59.       else
  60.       {
  61.          margin = 20;
  62.       }
  63.       obstacles[tracklength]._x = bikes[_loc1_]._x - obstacles._x + margin;
  64.       obstacles[tracklength]._y = bikes[_loc1_]._y - obstacles._y;
  65.    }
  66. }
  67. function usextra(who)
  68. {
  69.    if(xtra[who] == "fuel")
  70.    {
  71.       eval("xtraloop" + who).onEnterFrame = function()
  72.       {
  73.          if(!paused)
  74.          {
  75.             if(xtracounter[who] == 1 and who == human)
  76.             {
  77.                playsound("accel");
  78.                damagebike(who,(0.08 + engine[who] / 3) * 5);
  79.             }
  80.             xtracounter[who]++;
  81.             bikes[who].chase.b.gotoAndStop("horse");
  82.             xvel[who] *= 1.05;
  83.             if(xtracounter[who] > 99)
  84.             {
  85.                xtracounter[who] = 0;
  86.                bikes[who].chase.b.horse.gotoAndPlay("off");
  87.                delete eval("xtraloop" + who).onEnterFrame;
  88.             }
  89.          }
  90.       };
  91.    }
  92.    else if(xtra[who] == "repair")
  93.    {
  94.       eval("xtraloop" + who).onEnterFrame = function()
  95.       {
  96.          if(!paused)
  97.          {
  98.             xvel[who] *= 0.8;
  99.             damagebike(who,-0.1);
  100.             if(damage[who] < 1)
  101.             {
  102.                delete eval("xtraloop" + who).onEnterFrame;
  103.             }
  104.          }
  105.       };
  106.    }
  107. }
  108. function changemoney(much)
  109. {
  110.    money += much;
  111.    mymoney = "$" + money;
  112.    starsbox.gotoAndPlay(2);
  113. }
  114. function damagebike(which, much)
  115. {
  116.    damage[which] += much + much * (4 - cauchomodel[which]) / 4;
  117.    if(which == human)
  118.    {
  119.       heat.gotoAndStop(Math.floor(damage[which]));
  120.       if(much > 0 and damage[which] > 20)
  121.       {
  122.          if(damage[which] < 50)
  123.          {
  124.             msg.txt = "HEATING!";
  125.          }
  126.          else if(damage[which] < 70)
  127.          {
  128.             msg.txt = "HEATING!";
  129.          }
  130.          else if(damage[which] < 100)
  131.          {
  132.             msg.txt = "OVERLOADING!";
  133.          }
  134.          else if(damage[which] > 100)
  135.          {
  136.             msg.txt = "ENGINE OVERLOADED!";
  137.          }
  138.          msg.gotoAndPlay(2);
  139.       }
  140.    }
  141.    if(damage[which] > 100)
  142.    {
  143.       explodecounter[which] = 2;
  144.       eval("xtraloop" + which).onEnterFrame = null;
  145.       mytrack[which] = bikes[which]._y;
  146.       yvel[which] = -15;
  147.       mode[which] = "falling";
  148.       keyb[which] = false;
  149.    }
  150. }
  151. function forcewinners()
  152. {
  153.    motorsnd.stop();
  154.    tosort = new Array();
  155.    winnerlist = new Array();
  156.    n = 1;
  157.    while(n <= muchbikes)
  158.    {
  159.       tosort[n] = kilometer[n];
  160.       n++;
  161.    }
  162.    tosort.sort();
  163.    n = 1;
  164.    while(n <= muchbikes)
  165.    {
  166.       s = 1;
  167.       while(s <= muchbikes)
  168.       {
  169.          if(tosort[n] == kilometer[s])
  170.          {
  171.             winnerlist[n] = s;
  172.          }
  173.          s++;
  174.       }
  175.       n++;
  176.    }
  177.    n = 1;
  178.    while(n <= muchbikes)
  179.    {
  180.       tosort[n] = winnerlist[muchbikes - n + 1];
  181.       n++;
  182.    }
  183.    muchwinners = muchbikes;
  184.    if(muchwinners > 3)
  185.    {
  186.       muchwinners = 3;
  187.    }
  188.    while(arrived < muchwinners)
  189.    {
  190.       arrived++;
  191.       f = 1;
  192.       while(f <= muchwinners)
  193.       {
  194.          if(playerstate[tosort[f]] != "winner")
  195.          {
  196.             winner[arrived] = tosort[f];
  197.             if(playerstate[tosort[f]] == "alive")
  198.             {
  199.                myminutes = 0;
  200.                myseconds = Math.round(14 * (muchbikes + f) + random(10));
  201.                if(myseconds > 60)
  202.                {
  203.                   myseconds -= 60;
  204.                   if(myseconds < 10)
  205.                   {
  206.                      myseconds += "0";
  207.                   }
  208.                   myminutes++;
  209.                }
  210.                winnertime[arrived] = "0" + myminutes + ":" + myseconds + ":" + Math.round(Number(arrived * (random(7) + 10)));
  211.             }
  212.             else
  213.             {
  214.                if(bikers[tosort[f]] == bikers[human])
  215.                {
  216.                   temphuman = bikers[human];
  217.                }
  218.                bikers[tosort[f]] = 7;
  219.                winnertime[arrived] = "99:99:99";
  220.             }
  221.             playerstate[tosort[f]] = "winner";
  222.             break;
  223.          }
  224.          f++;
  225.       }
  226.    }
  227.    screen = "winners";
  228.    front.play();
  229.    paused = true;
  230. }
  231. function savegame()
  232. {
  233.    saved.data.muchbikes = muchbikes;
  234.    saved.data.biker = bikers[human];
  235.    saved.data.saved = 1;
  236.    saved.data.caucho = caucho;
  237.    saved.data.motor = motor;
  238.    saved.data.engine = engine[human];
  239.    saved.data.cauchomodel = cauchomodel[human];
  240.    saved.data.weapon = weapon[human];
  241.    saved.data.weaponcounter = weaponcounter[human];
  242.    saved.data.xtra = xtra[human];
  243.    saved.data.money = money;
  244. }
  245. function loadgame()
  246. {
  247.    muchbikes = human = saved.data.muchbikes;
  248.    bikers[human] = models[human] = saved.data.biker;
  249.    caucho = saved.data.caucho;
  250.    motor = saved.data.motor;
  251.    engine[human] = saved.data.engine;
  252.    cauchomodel[human] = saved.data.cauchomodel;
  253.    weapon[human] = saved.data.weapon;
  254.    weaponcounter[human] = saved.data.weaponcounter;
  255.    xtra[human] = saved.data.xtra;
  256.    money = saved.data.money;
  257.    mymoney = "$" + money;
  258. }
  259. function murdered()
  260. {
  261.    if(murder == false)
  262.    {
  263.       murder = true;
  264.       if(explodecounter[human] < 0)
  265.       {
  266.          damagebike(human,200);
  267.       }
  268.       if(winnercounter[human] > 0)
  269.       {
  270.          winnercounter[human] = -10;
  271.          obstacles._x += 2;
  272.          xvel[human] *= -10;
  273.          bikes[human]._x -= 10;
  274.       }
  275.       mafiamission = "failed";
  276.       paused = true;
  277.       mafia.play();
  278.    }
  279. }
  280. function soundbase(which)
  281. {
  282.    sndtrack.stop();
  283.    sndtrack = null;
  284.    sndtrack = new Sound(snd1);
  285.    sndtrack.attachSound(which);
  286.    sndtrack.setVolume(60);
  287.    sndtrack.start(0,999999999);
  288. }
  289. function playsound(which)
  290. {
  291.    eventsound = null;
  292.    eventsound = new Sound(snd2);
  293.    eventsound.attachSound(which);
  294.    eventsound.start();
  295. }
  296. _quality = "LOW";
  297. stop();
  298. gravity = 1;
  299. friction = 0.9;
  300. bounce = 0.3;
  301. human = 1;
  302. motorstarted = false;
  303. explodecounter = new Array();
  304. fadebike = new Array();
  305. cauchomodel = new Array();
  306. motorkind = new Array();
  307. engine = new Array();
  308. xvel = new Array();
  309. playerstate = new Array();
  310. yvel = new Array();
  311. bikelaps = new Array();
  312. kilpercent = new Array();
  313. kilometer = new Array();
  314. mode = new Array();
  315. mytrack = new Array();
  316. bikers = new Array();
  317. models = new Array();
  318. rampcounter = new Array();
  319. rotatecounter = new Array();
  320. oilcounter = new Array();
  321. tachuelascounter = new Array();
  322. gumcenter = new Array();
  323. gumcounter = new Array();
  324. poisoncounter = new Array();
  325. ongroundcounter = new Array();
  326. mytrackcounter = new Array();
  327. weapon = new Array();
  328. weaponcounter = new Array();
  329. xtra = new Array();
  330. xtracounter = new Array();
  331. xtracounter = new Array();
  332. keyb = new Array();
  333. damage = new Array();
  334. muchbikes = 4;
  335. n = 1;
  336. while(n <= muchbikes)
  337. {
  338.    xvel[n] = 0.1;
  339.    engine[n] = 1;
  340.    cauchomodel[n] = 1;
  341.    motorkind = 1;
  342.    n++;
  343. }
  344. center = 300;
  345. rightcenter = center + center / 2;
  346. leftcenter = center - center / 2;
  347. trackcounter = 0;
  348. seconds = minutes = milliseconds = 0;
  349. heat[n].model.gotoAndStop(1);
  350. weaponitems = new Array();
  351. weaponitems[0] = "blank";
  352. weaponitems[1] = "banana";
  353. weaponitems[2] = "tachuelas";
  354. weaponitems[3] = "gum";
  355. weaponitems[4] = "poison";
  356. xtraitems = new Array();
  357. xtraitems[0] = "blank";
  358. xtraitems[1] = "repair";
  359. xtraitems[2] = "fuel";
  360. backscreen = new Array();
  361. muchbikes = 2;
  362. winnercounter = new Array();
  363. winner = new Array();
  364. winnertime = new Array();
  365. arrived = 0;
  366. obstaclekind = new Array();
  367. obstaclekind[0] = "grass";
  368. obstaclekind[1] = "jumper";
  369. obstaclekind[2] = "oil";
  370. obstaclekind[3] = "dumb";
  371. obstaclekind[4] = "ramp";
  372. obstaclekind[5] = "star";
  373. motor = "motor1";
  374. caucho = "caucho1";
  375. tracklength = 10;
  376. changemoney(150);
  377. order = new Array();
  378. saved = SharedObject.getLocal("sikidsrb");
  379. score = saved.data.score;
  380. playername = new Array();
  381. playername[1] = "rocket dude";
  382. playername[2] = "alien farm";
  383. playername[3] = "red gallito";
  384. playername[4] = "punk guy";
  385. playername[5] = "blue elvis";
  386. playername[6] = "evil clown";
  387. motorsnd = new Sound(snd3);
  388. motorsnd.attachSound("motorsnd");
  389.